package com.rabbiter.hospital.config;

import com.rabbiter.hospital.interceptors.JwtInterceptor;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Component
public class InterceptorConfig implements WebMvcConfigurer {
    /**
     * 添加拦截器
     * 该方法用于注册自定义的拦截器，用于处理特定路径的请求前后的处理逻辑
     * @param registry 拦截器注册对象，用于向Spring框架注册自定义拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册JwtInterceptor拦截器，拦截匹配"/666"路径的所有请求
        // 并排除对"/patient/pdf"路径和任何以"/login"结尾路径的拦截
        registry.addInterceptor(new JwtInterceptor())
                .addPathPatterns("/666")
                .excludePathPatterns("/patient/pdf")
                .excludePathPatterns("/**/login");
    }

}
